dl-snapshot: be more forgiving to triples
authorCody P Schafer <dev@codyps.com>
Mon, 17 Nov 2014 02:35:19 +0000 (21:35 -0500)
committerCody P Schafer <dev@codyps.com>
Thu, 20 Nov 2014 06:28:21 +0000 (01:28 -0500)
src/etc/dl-snapshot.py

index 096b02e60f52b1f02318e8c0bd23e16e0bba6f04..47c4a430cc837c6985ada5a36718d013421b0f38 100644 (file)
@@ -25,21 +25,45 @@ win32 = lines[5]
 win64 = lines[6]
 triple = sys.argv[1]
 
-if triple == 'i686-unknown-linux-gnu':
-    me = linux32
-elif triple == 'x86_64-unknown-linux-gnu':
-    me = linux64
-elif triple == 'i686-apple-darwin':
-    me = mac32
-elif triple == 'x86_64-apple-darwin':
-    me = mac64
-elif triple == 'i686-pc-windows-gnu':
-    me = win32
-elif triple == 'x86_64-pc-windows-gnu':
-    me = win64
+ts = triple.split('-')
+arch = ts[0]
+if len(ts) == 2:
+    vendor = 'unknown'
+    target_os = ts[1]
 else:
+    vendor = ts[1]
+    target_os = ts[2]
+
+intel32 = (arch == 'i686') or (arch == 'i586')
+
+me = None
+if target_os == 'linux':
+    if intel32:
+        me = linux32
+        new_triple = 'i686-unknown-linux-gnu'
+    elif arch == 'x86_64':
+        me = linux64
+        new_triple = 'x86_64-unknown-linux-gnu'
+elif target_os == 'darwin':
+    if intel32:
+        me = mac32
+        new_triple = 'i686-apple-darwin'
+    elif arch == 'x86_64':
+        me = mac64
+        new_triple = 'x86_64-apple-darwin'
+elif target_os == 'windows':
+    if intel32:
+        me = win32
+        new_triple = 'i686-pc-windows-gnu'
+    elif arch == 'x86_64':
+        me = win64
+        new_triple = 'x86_64-pc-windows-gnu'
+
+if me is None:
     raise Exception("no snapshot for the triple: " + triple)
 
+triple = new_triple
+
 platform, hash = me.strip().split()
 
 tarball = 'cargo-nightly-' + triple + '.tar.gz'